#include "DisplayNode.h"
#include <QtDebug>

DisplayNode::DisplayNode() 
    :m_in(new AbsIoNode(this, AbsIoNode::input)) 
    , m_content("")
{ 
    registerIoNode("input", m_in);
}

inline DisplayNode::~DisplayNode() { }

QString DisplayNode::lastErrorMsg()
{
    return QString();
}

QString DisplayNode::displayText()
{
    if(m_content.isEmpty()) {
        return nodeName();
    } else {
        return m_content;
    }
}

QVariantMap DisplayNode::getParams()
{
    return QVariantMap();
}

void DisplayNode::setParams(QVariantMap paramsMap) 
{
    Q_UNUSED(paramsMap);
}

bool DisplayNode::run()
{
    if (m_handle)
        m_handle->contentUpdate();

    m_content = QString("%1").arg((m_in->variable()));
    //qDebug() << "Display:" << *(m_in->variable());
    return true;
}

QString DisplayNode::nodeName()
{
    return QObject::tr("Disp");
}
